package wx.use.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import wx.common.util.WXJSON;
import wx.use.entity.WXUserPojo;
import wx.use.service.WXUserPojoService;

@RestController
@RequestMapping("/use")
public class WXUserPojoController {
	@Resource
	private WXUserPojoService wxUserPojoService;
	@RequestMapping(value ="/add", method = RequestMethod.POST)
	public String add(WXUserPojo wxUserPojo) {

		String result=wxUserPojoService.WXUserPojoAdd(wxUserPojo);
		return result;
	}
	
	
	@RequestMapping(value ="/del", method = RequestMethod.POST)
	public String del(WXUserPojo wxUserPojo) {
		wxUserPojo.setWX_Del(1);
		String result=wxUserPojoService.WXUserPojoDel(wxUserPojo);
		return result;
	}
	
	
	@RequestMapping(value ="/upd", method = RequestMethod.POST)
	public String upd(WXUserPojo wxUserPojo) {

		String result=wxUserPojoService.WXUserPojoUpd(wxUserPojo);
		return result;
	}
	
	@RequestMapping(value ="/list",method = RequestMethod.POST)
	public List<WXUserPojo>wxUserPojoList(WXUserPojo wxUserPojo){
		List<WXUserPojo>li=wxUserPojoService.WXUserPojoList(wxUserPojo);
		return li;
	}
	
    @RequestMapping(value ="/listpage")
    public String wxUserPojoListpage(WXUserPojo wxUserPojo) {
        // TODO Auto-generated method stub
        int size=wxUserPojoService.WXUserPojoPageTotal(wxUserPojo);
        List<WXUserPojo> li=new ArrayList<WXUserPojo>();
        
        if(size>0){
            li=wxUserPojoService.WXUserPojoList(wxUserPojo);
        }

        Map<String,Object> map=new HashMap<String,Object>();
        map.put("total",size);
        map.put("rows",li  );
        String result= WXJSON.objectToJsonStr(map);
        return result;
    }
}


